MACRO(INTEGRATE_BOOST)
    SET(BOOST_COMPONENTS ${ARGV})
    IF(NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "")
        FILE( TO_CMAKE_PATH $ENV{BOOST_ROOT} BOOST_ROOT )
        IF( NOT EXISTS ${BOOST_ROOT} )
            MESSAGE( STATUS  ${BOOST_ROOT} " does not exist. Checking if BOOST_ROOT was a quoted string.." )
            STRING( REPLACE "\"" "" BOOST_ROOT ${BOOST_ROOT} ) 
            IF( EXISTS ${BOOST_ROOT} )
                MESSAGE( STATUS "After removing the quotes " ${BOOST_ROOT} " was now found by CMake" )
            ENDIF( EXISTS ${BOOST_ROOT})
        ENDIF( NOT EXISTS ${BOOST_ROOT} )
            # Save the BOOST_ROOT in the cache
        IF( NOT EXISTS ${BOOST_ROOT} )
            MESSAGE( WARNING "BOOST_ROOT does not exist." )
        ELSE(NOT EXISTS ${BOOST_ROOT})
            SET(BOOST_ROOT ${BOOST_ROOT} CACHE STRING "Set the value of BOOST_ROOT to point to the root folder of your boost install." FORCE)
        ENDIF( NOT EXISTS ${BOOST_ROOT} )
    ENDIF(NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "")

    # if(NOT BOOST_ROOT )
    #    MESSAGE( WARNING "Please set the BOOST_ROOT environment variable." )
    # endif(NOT BOOST_ROOT )
    SET(Boost_USE_STATIC_LIBS       ON)
    SET(Boost_USE_MULTITHREADED     ON)
    FIND_PACKAGE(Boost COMPONENTS ${BOOST_COMPONENTS} REQUIRED)

    IF( Boost_FOUND ) 
        STRING(COMPARE LESS "${Boost_VERSION}" 1.50.0 VersionIncompatible)
        IF(VersionIncompatible)
            MESSAGE(FATAL_ERROR "Boost ${Boost_VERSION} not supported. Only 1.50.0 version and higher is supported.")
        ELSE(VersionIncompatible)
            MESSAGE (STATUS "Found Boost ${Boost_VERSION} -- ${Boost_LIBRARIES}")
            INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIRS} )
            LINK_LIBRARIES(${BOOST_LIBRARYDIR})
        ENDIF(VersionIncompatible)
    ENDIF()
ENDMACRO(INTEGRATE_BOOST)
